﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Wijmo.Master" AutoEventWireup="true" CodeBehind="InMemoryDocuments.aspx.cs" Inherits="ControlExplorer.C1ReportViewer.InMemoryDocument" %>

<%@ Register Assembly="C1.Web.Wijmo.Controls.3" Namespace="C1.Web.Wijmo.Controls.C1ReportViewer" TagPrefix="C1ReportViewer" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <C1ReportViewer:C1ReportViewer runat="server" ID="C1ReportViewer1" FileName="InMemoryBasicTable" Zoom="75%" Height="475px" Width="100%">
    </C1ReportViewer:C1ReportViewer>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Description" runat="server">
    <p>
        动态（位于内存）报表样例</p>
    <p>
        动态报表可以在运行时创建。您可以通过静态的 <strong>C1ReportViewer.RegisterDocument </strong>行为来注册动态报表。</p>
    <p>
        <strong>C1ReportViewer.RegisterDocument</strong> 行为接受两个参数： 第一个参数是动态报表文档的名字；第二个参数是一个委托，为了生成一个报表文档而被调用。</p>
    <p>
        <strong>FileName</strong> 属性应当被设置为动态报表的名字。它可以作为 <strong>C1ReportViewer.RegisterDocument</strong> 行为的第一个参数。</p>
    <p>
        以下是一段代码，来说明怎样注册并且呈现动态报表文档:</p>
    <pre class="controldescription-code">
ASPX code:
-------------
	&lt;C1ReportViewer:C1ReportViewer runat="server" ID="C1ReportViewer1" 
		FileName="InMemoryBasicTable" Zoom="75%" Height="475px" Width="100%"&gt;
	&lt;/C1ReportViewer:C1ReportViewer&gt; 
ASPX.CS code:
-------------
	public partial class InMemoryDocument : System.Web.UI.Page
	{
		protected void Page_Load(object sender, EventArgs e)
		{
			C1ReportViewer.RegisterDocument("InMemoryBasicTable",
						BasicTable.MakeDoc);
		}
	}

	/// &lt;summary&gt;
	/// BasicTable in-memory document.
	/// &lt;/summary&gt;
	public class BasicTable
	{
		static public C1PrintDocument MakeDoc()
		{
			C1PrintDocument doc = C1ReportViewer.CreateC1PrintDocument();
			RenderText rtxt1 = new RenderText(doc);
			rtxt1.Text = "Some text goes here";
			rtxt1.Style.Font = new Font(rtxt1.Style.Font.FontFamily, 14);
			rtxt1.Style.Padding.Bottom = new C1.C1Preview.Unit("5mm");
			doc.Body.Children.Add(rtxt1);
			return doc;
		}
	}
</pre>
    <strong>注意</strong>:&nbsp; 您可以以不同的名字注册及动态报表并且通过改变 <strong>FileName</strong> 属性在报表间进行交换。
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="ControlOptions" runat="server">
</asp:Content>
